package com.travel.server.manager.impl.controller.ueditor;

import com.travel.server.manager.impl.ueditor.ActionEnter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author: LiZhenhui
 * @Date: 2018\11\11 0011 15:25
 * @Desc:
 */
@Controller
@Slf4j
public class UeditorController {

    @RequestMapping(value = "/ue/config")
    public void config(HttpServletRequest request, HttpServletResponse response){
        response.setContentType("application/json");
        String rootPath = request.getSession().getServletContext().getRealPath("/");
        try {
            String exec = new ActionEnter(request, rootPath).exec();
            PrintWriter writer = response.getWriter();
            writer.write(exec);
            writer.flush();
            writer.close();
        } catch (IOException e) {
            log.error("富文本上传文件异常：", e);
        }

    }
}
